﻿@model EasyLift.TMS.Web.Models.VehicleViewModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/MicrosoftMvcValidation.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#Vehicle_InsuranceExpiryDate").datepicker({
            dateFormat: 'mm/dd/yy',
            numberOfMonths: 1,
            showButtonPanel: true,
            changeMonth: true,
            changeYear: true
        });
    });
</script>

<style type="text/css">
    .ui-autocomplete-loading
    {
        background: white url('/Content/ui-anim_basic_16x16.gif') right center no-repeat;
    }
</style>

<script type="text/javascript">
    $(function () {

        $("#Vehicle_DriverAssigned").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/Driver/GridData",
                    dataType: "json",
                    data: {
                        sidx: "CivilID",
                        sord: "DESC",
                        page: 1,
                        rows: 10,
                        _search: true,
                        searchField: "All",
                        searchOper: "cn",
                        searchString: request.term
                    },
                    success: function (data) {
                        response($.map(data.rows, function (item) {
                            return {
                                label: item.cell[1].toString(),
                                value: item.id,
                                lastname: item.cell[2].toString(),
                                country: item.cell[4].toString(),
                                status: item.cell[6].toString(),
                                id: item.id
                            }
                        }));
                    }
                });
            },
            minLength: 0,
            delay: 100,
            focus: function (event, ui) {
                $(this).val(ui.item.value);
                return false;
            },
            select: function (event, ui) {
                $("#Driver_VehicleAssigned").val(ui.item.id);
                return false;
            },
            open: function () {
                $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
            },
            close: function () {
                $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
            }
        })
        .data("autocomplete")._renderItem = function (ul, item) {
            return $("<li></li>")
				.data("item.autocomplete", item)
				.append("<a><span class='ui-icon ui-icon-person' style='float: left; margin-right: .3em;'></span>" + item.id + "<br>" + item.label + "," + item.lastname + "," + item.country + "<br>" + item.status + "</a>")
				.appendTo(ul);
        };

        $("#Vehicle_DriverAssigned").focus(function () { $(this).keydown(); })

    });
</script>

@{ Html.EnableClientValidation(); }
@{
   
  
    string strAction = "Create";
    if (Request.Url.ToString().Contains("/Edit/"))
    {
        strAction = "Edit";
    }

    using (Html.BeginForm(strAction, "Vehicle", new { id = Model.Vehicle.VehicleNumber }, FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Vehicle</legend>
        <div id="ActionLinkButtons">
            <input type="submit" value="Save" />
            @Html.ActionLink("Back to List", "Index")
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.VehicleNumber)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.VehicleNumber)
            @Html.ValidationMessageFor(model => model.Vehicle.VehicleNumber)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.DoorNo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.DoorNo)
            @Html.ValidationMessageFor(model => model.Vehicle.DoorNo)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.LicensePlateNumber)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.LicensePlateNumber)
            @Html.ValidationMessageFor(model => model.Vehicle.LicensePlateNumber)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.VIN)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.VIN)
            @Html.ValidationMessageFor(model => model.Vehicle.VIN)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.MasterListNo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.MasterListNo)
            @Html.ValidationMessageFor(model => model.Vehicle.MasterListNo)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.CompanyCode)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.CompanyCode)
            @Html.ValidationMessageFor(model => model.Vehicle.CompanyCode)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.BodyType)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.BodyType)
            @Html.ValidationMessageFor(model => model.Vehicle.BodyType)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Make)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Make)
            @Html.ValidationMessageFor(model => model.Vehicle.Make)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Model)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Model)
            @Html.ValidationMessageFor(model => model.Vehicle.Model)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Year)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Year)
            @Html.ValidationMessageFor(model => model.Vehicle.Year)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Color)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Color)
            @Html.ValidationMessageFor(model => model.Vehicle.Color)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.InsuranceCompany)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.InsuranceCompany)
            @Html.ValidationMessageFor(model => model.Vehicle.InsuranceCompany)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.InsuranceExpiryDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.InsuranceExpiryDate)
            @Html.ValidationMessageFor(model => model.Vehicle.InsuranceExpiryDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.RegistrationExpiryDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.RegistrationExpiryDate)
            @Html.ValidationMessageFor(model => model.Vehicle.RegistrationExpiryDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.AppsGivenDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.AppsGivenDate)
            @Html.ValidationMessageFor(model => model.Vehicle.AppsGivenDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.ASGPassIssueDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.ASGPassIssueDate)
            @Html.ValidationMessageFor(model => model.Vehicle.ASGPassIssueDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.ASGPassExpiryDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.ASGPassExpiryDate)
            @Html.ValidationMessageFor(model => model.Vehicle.ASGPassExpiryDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.TrailorNo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.TrailorNo)
            @Html.ValidationMessageFor(model => model.Vehicle.TrailorNo)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.KmIn)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.KmIn)
            @Html.ValidationMessageFor(model => model.Vehicle.KmIn)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.KmOut)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.KmOut)
            @Html.ValidationMessageFor(model => model.Vehicle.KmOut)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.SpodNumber)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.SpodNumber)
            @Html.ValidationMessageFor(model => model.Vehicle.SpodNumber)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.SpodExpiryDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.SpodExpiryDate)
            @Html.ValidationMessageFor(model => model.Vehicle.SpodExpiryDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.J2ExpiryDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.J2ExpiryDate)
            @Html.ValidationMessageFor(model => model.Vehicle.J2ExpiryDate)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Remark1)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Remark1)
            @Html.ValidationMessageFor(model => model.Vehicle.Remark1)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Remark2)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Remark2)
            @Html.ValidationMessageFor(model => model.Vehicle.Remark2)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Remark3)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Remark3)
            @Html.ValidationMessageFor(model => model.Vehicle.Remark3)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Remark4)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Remark4)
            @Html.ValidationMessageFor(model => model.Vehicle.Remark4)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Remark5)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Remark5)
            @Html.ValidationMessageFor(model => model.Vehicle.Remark5)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.Remark6)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.Remark6)
            @Html.ValidationMessageFor(model => model.Vehicle.Remark6)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.DriverAssigned)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.DriverAssigned)
            @Html.ValidationMessageFor(model => model.Vehicle.DriverAssigned)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.VehicleMissionStatusCode)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Vehicle.VehicleMissionstatus.VehicleMissionStatusDescription, new {readOnly = true})
            @Html.ValidationMessageFor(model => model.Vehicle.VehicleMissionStatusCode)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Vehicle.VehicleQCStatusCode)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Vehicle.VehicleQCStatusCode,Model.QCStatus)
            @Html.ValidationMessageFor(model => model.Vehicle.VehicleQCStatusCode)
        </div>

        <div id="ActionLinkButtonsBottom">
            <input type="submit" value="Save" />
            @Html.ActionLink("Back to List", "Index")
        </div>
    </fieldset>
    }
}
